AFORMAT
FORMAT
IFORMAT

Syntax: FORMAT [#channel,] medium
   and: AFORMAT [device_]name
   and: IFORMAT [device_]name
Location: QL ROM (FORMAT), ATARIDOS (AFORMAT and IFORMAT)

Each medium where data can be stored as files (disks, ramdisks, microdrives or hard disks) has to be given a structure which is recognisable by QDOS. This is done by FORMATting it. Each medium can also be given a name of up to ten characters long.

The command FORMAT clears a medium from scratch so that any data stored there is definitively lost.  Be careful!

The following standard devices can be formatted:

MDV1_ .. MDV8_ microdrive cartridges   
FLP1_ .. FLP8_ floppy disks   
RAM1_ .. RAM8_ ramdisks   
WIN1_ .. WIN8_ hard disks

Depending on the type of medium, several additions to the pure medium name are possible:

MDV  Up to ten characters can be added, these
     will form the name of the cartridge, eg:

     FORMAT mdv2_SuperBASIC

FLP  As with microdrive cartridges, a medium
     name can be added. If the eleventh character
     of the name is an asterisk (*), the disk
     will be formatted single sided.

     In order to use the single sided only option,
     it is necessary to put the whole parameter
     in quotes, eg:

     FORMAT "flp1_TEST *"

     This is not applicable to HD and ED disks:
     their density will also be affected, making
     them single sided double density (SSDD).

     With Super Gold Card, Gold Card and SMS,
     an appended asterisk plus a letter which
     indicates the density will format the disk
     accordingly:
     S, D, H and E are allowed, eg:
  
     FORMAT "flp1_TEST*h"

RAM  This depends very much on the ramdisk drivers:
     With standard static ramdisks, you need to
     specify how many sectors are to be allocated
     to the ramdisk by adding the number of sectors
     to the medium name, eg.


     FORMAT ram1_200
  
     formats ram2_ to 200 sectors (100K). These
     static ramdisks must be FORMATted before use.

     On the other hand, the Qjump ramprt ramdisk
     (provided with Qpac 2 and various expansion
     boards, including Trump Card, Gold Card and
     Super Gold Card) is dynamic - it adapts its
     size automatically to the size of the files
     being stored on it - there is no need to
     FORMAT the ramdisk prior to use. This can
     however also be used as a static ramdisk.

     Trump Card, Super Gold Card and Gold Card
     ROMs also contain a special variant of a
     ramdisk which allows you to produce an image
     of a microdrive cartridge on a ramdisk,
     for example by using FORMAT ram4_mdv2. Faulty
     files are marked with an asterisk added to
     the end of their filenames.

WIN  A medium name can normally be stated, as
     with a microdrive cartridge. Please check
     the documentation of the hard disk drivers,
     they differ very much!

     On the THOR, an asterisk needs to be included,
     eg. FORMAT 'win1_*HARDDISK', see below.

     SMS for ATARI computers and QXL / QPC, expects
     you to have already partitioned the hard disk
     using the computer's native commands.

     On ATARIs, under SMSQ/E you then need to
     identify the drive and partition using WIN_DRIVE.
     After that, you can use the normal QL FORMAT
     command on all these systems, however, SMSQ/E
     has adopted a level of protection which
     insists that you must use the WIN_FORMAT
     command before FORMAT and the FORMAT
     command itself will display two characters on
     screen and ask you to type them in.  You should
     then use WIN_FORMAT to protect the partition again.

     The standard drivers for the ST/QL Emulators
     adopt a form of protection in that you will need
     to type in the two characters shown on screen as
     with SMSQ/E.  You can also only FORMAT a hard disk
     from SuperBasic Job 0 and then only when Channel
     #0 is OPEN.  If the hard disk has already been
     partitioned by the Atari ST (the first partition
     will normally be marked GEM or BGM), then you
     will be asked to enter the number of the first
     partition to be used by QDOS and the number of
     subsequent partitions ot be used for this disk.

     Under SMSQ/E on the QXL or QPC, this same two-
     level protection is adopted.  However, instead
     of passing the medium name of the hard-disk, you
     have to pass the size of the QL hard disk to be
     created in megabytes, for example:

     FORMAT WIN1_20

     This will create a 20Megabyte harddisk on PC
     drive C:

After formatting, FORMAT will either report that the process has failed (error -14), because there was no cartridge/disk in the drive or if the medium was faulty. The command will also fail if the given device was write-protected. 

If everything was okay, a small message is printed to the specified channel (default #1) indicating how many sectors could be achieved and how many were good. If the two numbers differ, QDOS will have marked some sectors as bad and will ignore them. However, experience shows that if the difference between the two numbe very dangerous to store important data on those disks/cartridges.

AFORMAT and IFORMAT are very similar, except that they do not report the outcome.  AFORMAT formats disks in Atari format, whereas IFORMAT formats them in IBM PS/2 format.  Add an asterisk as the last character to format single sided.

Example:
FORMAT mdv2_Startup           formats cartridge in
                              microdrive 2
FORMAT "flp1_backup*d"        double sided, double density
FORMAT ram1_100               format ramdisk 1 to 50K


SMS NOTES:
As with Minerva, you cannot FORMAT a medium if there are any files open on that medium ('Is In Use' error is reported).

If there is a problem during the FORMAT process, SMS will emit a series of BEEPs.  However, be warned that an error messaage is not always displayed and the FORMAT may appear to have completed correctly!!

THOR XVI NOTES:
The THOR XVI, v6.37 (and later) allows a variant of the medium name to deal with the THOR's hard disk: 

FORMAT "win1_options*name"

The available options which can be specified are:

/C Certify drive before formatting
   - this reconstructs the THOR's
   defect list, describing the bad
   sectors and tracks
/Q Quick reformat - merely sets up
   new directory map
/F Fast reformat  - does not verify
   the disk
/Gn Set group or cluster size in blocks. 
    Default = /G16
/Dn Set directory size in number of
    groups or clusters.
    Default = /D2

CROSS-REFERENCE:
Before formatting, the number of tracks on a disk can be specified with FLP_TRACK.  HD and ED disks can be formatted to different densities if FLP_DENSITY was used to override automatic detection of the density.
See WIN_FORMAT for hard disk protection.
DMEDIUM_xxx functions return details about how a medium has been formatted.
